
import { Inject, Injectable } from '@nestjs/common'
import { JwtService } from '@nestjs/jwt'


/**
 * 令牌服务
 */
@Injectable()
export class TokenService {
  constructor(
    private jwtService: JwtService,
  ) { }

  generateToken(user: any) {
    const payload = {
      ...user
    };

    return this.jwtService.sign(payload);
  }

  async removeAccessToken(value: string) {
    // 查询 token 是否存在
    // const accessToken = await AccessTokenEntity.findOne({
    //   where: { value },
    // })
    //存在则删除
    // if (accessToken) {
    //   this.redis.del(genOnlineUserKey(accessToken.id))
    //   await accessToken.remove()
    // }
  }
}
